import { Select } from 'antd';
import type { Bean } from '../../interface';

export const strListToSelectOptions = (list: string[]) =>
  list.map((item, index: number) => (
    <Select.Option title={item} key={`${index}_${item}`} value={`${item}`}>
      {item}
    </Select.Option>
  ));

export const listToSelectOptions = (list: Bean[], itemKey = { text: 'title', value: 'value' }) =>
  list.map((item, index: number) => (
    <Select.Option
      title={item[itemKey.text]}
      key={`${index}_${itemKey.value}`}
      value={`${item[itemKey.value]}`}
    >
      {item[itemKey.text]}
    </Select.Option>
  ));
